﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.gui.reprise {
    import reprise.css.*;
    import reprise.events.*;
    import flash.display.*;
    import flash.geom.*;
    import reprise.ui.renderers.*;
    import reprise.css.propertyparsers.*;

    public class PetsBackgroundRenderer extends DefaultBackgroundRenderer {

        override protected function imageLoader_complete(_arg1:ResourceEvent=null):void{
            if (((((!(_arg1.success)) || ((m_styles.backgroundImage == null)))) || ((m_styles.backgroundImage == Background.IMAGE_NONE)))){
                clearBackgroundImage();
                return;
            };
            if (m_inactiveBackgroundAnimationContainer){
                m_inactiveBackgroundAnimationContainer.parent.removeChild(m_inactiveBackgroundAnimationContainer);
                m_inactiveBackgroundAnimationContainer = null;
            };
            var _local2:Sprite = m_activeBackgroundAnimationContainer;
            _local2.addChild(m_backgroundImageLoader.content());
            if ((((m_backgroundImageLoader.content() is MovieClip)) && (m_styles.backgroundAnimationControl))){
                applyAnimationControls();
            };
            var _local3:Number = _local2.width;
            var _local4:Number = _local2.height;
            var _local5:Rectangle = constructScale9Rect(_local3, _local4);
            var _local6 = (m_complexStyles.getStyle("backgroundImageType").valueOf() == "animation");
            if (_local5 != null){
                if ((((m_backgroundImageLoader.content() is MovieClip)) && (_local6))){
                    _local2 = m_backgroundImageLoader.content();
                } else {
                    _local2.scale9Grid = _local5;
                };
                _local2.x = (_local2.y = 0);
                _local2.width = m_width;
                _local2.height = m_height;
                m_backgroundImageContainer.graphics.clear();
                return;
            };
            _local2.scale9Grid = null;
            _local2.scaleX = (_local2.scaleY = 1);
            var _local7:Point = new Point((m_styles.backgroundPositionX | 0), (m_styles.backgroundPositionY | 0));
            var _local8:CSSProperty = m_complexStyles.getStyle("backgroundPositionX");
            if (((_local8) && (_local8.isRelativeValue()))){
                _local7.x = Math.round(_local8.resolveRelativeValueTo((m_width - _local3)));
            };
            var _local9:CSSProperty = m_complexStyles.getStyle("backgroundPositionY");
            if (((_local9) && (_local9.isRelativeValue()))){
                _local7.y = Math.round(_local9.resolveRelativeValueTo((m_height - _local4)));
            };
            _local2.x = _local7.x;
            _local2.y = _local7.y;
            m_backgroundImageContainer.graphics.clear();
        }

    }
}//package net.wooga.pets.gui.reprise 
